#! /bin/bash
cat /dev/null > pw.txt
read -p "please input passwd:" P1
read -p "please input passwd again:" P2
if [ "$P1" = "$P2" ];then
	echo $P2 >> pw.txt
	echo $P1 >> pw.txt
	echo "passwd is correct."
	#exit 0
else
	echo "passwd is incorrect."
	exit 1
fi
rmcmd="echo yedpay | sudo -S passwd"
server_array=(31 32 33 35 36 37)
ipadd=192.168.2
for server in ${server_array[*]}
do
	echo "ssh to $server >>>"
	ssh -Tq ubuntu@$ipadd.$server $rmcmd --stdin < pw.txt
done
